import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;

public class LeeArmas {

	ArrayList<Arma> ListArmas = null;
	final String archNomb = "ArmasBD.txt";

	public LeeArmas() {

		try {
			File archN = new File(this.archNomb);
			FileReader archReader = new FileReader(archN);
			BufferedReader reader = new BufferedReader(archReader);
			String line = null;
			Arma auxi;
			ListArmas = new ArrayList<Arma>();
			while ((line=reader.readLine())!=null) {

				/* codigo nombre descripcion ataque defensa costo tipo */
				String codigo = null;
				String nombre = null;
				String descripcion = null;
				Integer ataque = null;
				Integer defensa = null;
				Integer costo = null;
				Integer tipo = null;
                                Character forma=null;
				
				String formador;
				int i = 0;
				formador = new String();
				
				while ((line.charAt(i) != '-') && (line.length() > i)) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				codigo = new String(formador);

				i++;
				formador = new String();
				while ((line.charAt(i) != '-') && (line.length() > i)) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				nombre = new String(formador);
				i++;

				formador = new String();
				while ((line.charAt(i) != '-') && (line.length() > i)) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				descripcion = new String(formador);

				formador = new String();
				i++;
				while ((line.length() > i) && (line.charAt(i) != '-')) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				ataque = new Integer(Integer.valueOf(formador));

				formador = new String();
				i++;
				while ((line.length() > i) && (line.charAt(i) != '-')) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				defensa = new Integer(Integer.valueOf(formador));

				formador = new String();
				i++;
				while ((line.length() > i) && (line.charAt(i) != '-')) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				costo = new Integer(Integer.valueOf(formador));

				formador = new String();
				i++;
				while ((line.length() > i) && (line.charAt(i) != '-') ) {
					formador = formador.concat(String.valueOf(line.charAt(i)));
					i++;
				}
				tipo = new Integer(Integer.valueOf(formador));

                                formador= new String();

                                while ((line.length()>i)){
                                    formador=formador.concat(String.valueOf(line.charAt(i)));
                                    i++;
                                }
                                forma=new Character(Character.valueOf(formador.charAt(formador.length()-1)));

				auxi = new Arma(codigo, nombre, descripcion, ataque, defensa,
						costo, tipo,forma);
				this.ListArmas.add(auxi);
			}
			reader.close();

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	void showlist() {
		for (Arma a : this.ListArmas) {
			a.show();
		}
	}
}
